//
// Created by liang on 25-8-4.
//
#include "Device_Motor.h"

#include <QTimer>



Device_Motor::Device_Motor(MotorType type, QObject* parent)
    : QObject(parent), m_type(type){

}


Device_Motor::~Device_Motor()
{

}


void Device_Motor::SetStatus(MotorStatus status) {
    if (m_status != status) {
        m_status = status;
    }
    emit StatusChanged(status);
}


bool Device_Motor::Stop(StopMode mode) {
    Q_UNUSED(mode);
    SetError("Stop operation not implemented");
    return false;
}

bool Device_Motor::SetSpeed(double speed) {
    if (speed <= 0 || speed > m_maxSpeed) {
        SetError("Invalid speed value");
        return false;
    }
    m_currentSpeed = speed;
    return true;
}

double Device_Motor::GetSpeed() {
    return m_currentSpeed;
}

bool Device_Motor::IsMoving() {
    return m_status == MotorStatus::Moving;
}

MotorStatus Device_Motor::GetStatus() {
    return m_status;
}

bool Device_Motor::SetAcceleration(double acc) {
    m_acceleration = acc;
    return true;
}

bool Device_Motor::SetDeceleration(double dec) {
    m_deceleration = dec;
    return true;
}

void Device_Motor::SetError(const QString& error) {

    emit ErrorOccurred(error);
}

void Device_Motor::setScantimer(double time) {
    scantimer = time;
}
